package com.rc.saas.mini.common.base;

import com.rc.saas.mini.common.constant.CommonConstant;
import com.rc.saas.mini.common.constant.HttpConstant;
import io.swagger.annotations.ApiModelProperty;

import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.Map;

/**
 * @Author: zcg
 * @CreateDate: 2022/5/13 10:02
 */
public class DataTResponse<T> implements Serializable {
    @ApiModelProperty(value = "200:成功；其它:失败")
    private int status; //200:成功；其它:失败
    @ApiModelProperty(value = "提示信息")
    private String message;
    @ApiModelProperty(value = "返回对象")
    private T data;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public DataTResponse() {
    }

    public DataTResponse(int status, String message) {
        this.status = status;
        this.message = message;
    }

    public DataTResponse(int status, String message, Map data) {
        this.status = status;
        this.message = message;
        this.data = (T) data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    public static DataTResponse SUCCESS() {
        return new DataTResponse(HttpConstant.STATUS_SUCCESS, CommonConstant.MSG_SUCCESS);
    }

    public static DataTResponse SUCCESS(String message) {
        return new DataTResponse(HttpConstant.STATUS_SUCCESS, message);
    }

    public static DataTResponse SUCCESS_DATA(Object object) {
        DataTResponse tResponse = new DataTResponse(HttpConstant.STATUS_SUCCESS, CommonConstant.MSG_SUCCESS);
        tResponse.setData(object);
        return tResponse;
    }

    public static DataTResponse FAIL() {
        return new DataTResponse(HttpConstant.STATUS_FAIL, CommonConstant.MSG_FAIL);
    }

    public static DataTResponse FAIL(String message) {
        return new DataTResponse(HttpConstant.STATUS_FAIL, message);
    }

    public static DataTResponse SC_OK() {
        return new DataTResponse(HttpServletResponse.SC_OK, "SC_OK");
    }

    public static DataTResponse SC_NOT_FOUND() {
        return new DataTResponse(HttpServletResponse.SC_NOT_FOUND, "SC_NOT_FOUND");
    }

    public static DataTResponse SC_BAD_REQUEST() {
        return new DataTResponse(HttpServletResponse.SC_BAD_REQUEST, "SC_BAD_REQUEST");
    }

    public static DataTResponse SC_FORBIDDEN() {
        return new DataTResponse(HttpServletResponse.SC_FORBIDDEN, "SC_FORBIDDEN");
    }

    public static DataTResponse SC_UNAUTHORIZED() {
        return new DataTResponse(HttpServletResponse.SC_UNAUTHORIZED, "SC_UNAUTHORIZED");
    }

    public static DataTResponse SC_INTERNAL_SERVER_ERROR() {
        return new DataTResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "SC_INTERNAL_SERVER_ERROR");
    }

    //public static DataTResponse customerError(String message) {
    //    return new DataTResponse(1001, message);
    //}
    public static DataTResponse FAIL_LOGIN() {
        return new DataTResponse(HttpConstant.STATUS_FAIL_LOGIN, CommonConstant.MSG_NO_LOGIN);
    }

    public static DataTResponse FAIL_LOGIN(String message) {
        return new DataTResponse(HttpConstant.STATUS_FAIL_LOGIN, message);
    }

}
